﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.YAML.CApExportToRTRYamlUtils
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Linq;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToRTR.YAML;

public static class CApExportToRTRYamlUtils
{
  public const string OriginMate = "Origin_";
  public const string AttachmentMate = "_To_";

  public static string GetRobotKinematicChildKey(string robotPrototypeName, ITxObject robotChild)
  {
    return $"{robotPrototypeName}_{robotChild.Name}";
  }

  public static TxVector GetRotation(this TxTransformation transformation)
  {
    return transformation.RotationRPY_ZYX;
  }

  public static string GetMateUniqueName(ITxObject attachmentParent, ITxObject child)
  {
    string mateName = $"{TxObjectEx.GetUniqueNameForRTR(attachmentParent, true)}_To_{TxObjectEx.GetUniqueNameForRTR(child, true)}";
    if (CApExportToRTRYamlMgr.Instance.Workcell.Mates.Any<Mate>((Func<Mate, bool>) (x => x.Name == mateName)))
      mateName = $"{TxObjectEx.GetUniqueNameForRTR(attachmentParent, false)}_To_{TxObjectEx.GetUniqueNameForRTR(child, false)}";
    return mateName;
  }
}
